﻿<%@ WebHandler Language="C#" Class="get" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;
using System.Collections.Generic;
using System.Web.SessionState;

public class get : IHttpHandler, IRequiresSessionState
{
    sqlhelp sql = new sqlhelp();
    SYS_Moduleresult result = new SYS_Moduleresult();
    string str = "";
    DataTable dt = new DataTable();
    List<SYS_Module> SYS_ModuleList = new List<SYS_Module>();
    public void ProcessRequest (HttpContext context) {
        try
        {
            if (context.Session["comid"] == null)
            {
                result.code = "-1";
                result.msg = "用户未登录";
                unit.send(context, result);
                return;
            }

            string Id = context.Session["comid"].ToString();
            //string Id = "9F1DFD1D-7BF3-479E-8C35-01A59D1AB167";

            string Type = "";
            if (context.Request["Type"] != null)
            {
                Type = context.Request["Type"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递Sno";
                unit.send(context, result);
                return;
            }

            string where = "where MainId = '" + Id + "' and Type = " + Type + "  and Enable = 1";

            str = "select * from SYS_WebDetail  " + where;
            dt = sql.myDataSet(str).Tables[0];
            int len = dt.Rows.Count;
            if (len > 0)
            {
                SYS_Module _SYS_Module = new SYS_Module();

                _SYS_Module.Id = dt.Rows[0]["Id"].ToString();
                _SYS_Module.MainId = dt.Rows[0]["MainId"].ToString();
                _SYS_Module.Sno = dt.Rows[0]["Sno"].ToString();
                _SYS_Module.Type = dt.Rows[0]["Type"].ToString();
                _SYS_Module.name = dt.Rows[0]["name"].ToString();
                _SYS_Module.text = dt.Rows[0]["text"].ToString();
                _SYS_Module.text1 = dt.Rows[0]["text1"].ToString();
                _SYS_Module.text2 = dt.Rows[0]["text2"].ToString();
                _SYS_Module.text3 = dt.Rows[0]["text3"].ToString();
                _SYS_Module.text4 = dt.Rows[0]["text4"].ToString();
                _SYS_Module.text5 = dt.Rows[0]["text5"].ToString();
                _SYS_Module.number = dt.Rows[0]["number"].ToString();
                _SYS_Module.height = dt.Rows[0]["height"].ToString();
                _SYS_Module.url = dt.Rows[0]["url"].ToString();
                _SYS_Module.auto_play = dt.Rows[0]["auto_play"].ToString();
                _SYS_Module.img = dt.Rows[0]["img"].ToString();
                _SYS_Module.showFontType = dt.Rows[0]["showFontType"].ToString();
                _SYS_Module.banner = dt.Rows[0]["banner"].ToString();
                _SYS_Module.time = dt.Rows[0]["time"].ToString();
                _SYS_Module.Show = dt.Rows[0]["Show"].ToString();
                


                result.data = _SYS_Module;
            }
            else
            {
                SYS_Module _SYS_Module = new SYS_Module();
                result.data = _SYS_Module;
                result.code = "1";
                result.msg = "";
            }
        }
        catch (Exception e1)
        {
            result.code = "0";
            result.msg = e1.Message;
        }
        unit.send(context, result);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

public class SYS_Moduleresult : result
{
    public SYS_Module data = new SYS_Module();

}

public class SYS_Module
{
    public string Id = "";
    public string MainId = "";
    public string Sno = "";
    public string Type = "";
    public string name = "";
    public string text = "";
    public string text1 = "";
    public string text2 = "";
    public string text3 = "";
    public string text4 = "";
    public string text5 = "";
    public string number = "";
    public string height = "";
    public string url = "";
    public string auto_play = "";
    public string img = "";
    public string showFontType = "";
    public string banner = "";
    public string time = "";
    public string Show = "";


}
